package App.Repository;

import App.Model.Account.CrmUser;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.NativeQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;

/**
 * Created by xw on 2019/1/29.
 */


@Repository
public class DemoRepository {


    //@PersistenceContext
    // private EntityManager em;

    private SessionFactory _factory;


    public List<CrmUser> findUsersNoPage() {

        String _queryString = "select id,username,password,recstatus from crm_user where id=53 ";
        // Query query = em.createNativeQuery(queryString, CrmUser.class);

        //List<CrmUser> result = query.getResultList();
        Session _session = _factory.openSession();
        NativeQuery _query = _session.createSQLQuery(_queryString);
        List<CrmUser> result = _query.addEntity(CrmUser.class).list();
        return result;
    }


}
